package com.mayikt.pay.service.impl;

import com.mayikt.pay.callback.template.AbstractPayCallbackTemplate;
import com.mayikt.pay.factory.TemplateFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@Service
public class PayAsynCallbackService {
    private static final String UNIONPAYCALLBACK_TEMPLATE = "unionPayCallback";

    /**
     * 银联支付异步回调函数
     */
    @PostMapping("/unionPayAsynCallback")
    @Transactional
    public String unionPayAsynCallback(HttpServletRequest req, HttpServletResponse resp){
        AbstractPayCallbackTemplate payCallbackTemplate = TemplateFactory.getPayCallbackTemplate(UNIONPAYCALLBACK_TEMPLATE);
        return payCallbackTemplate.asyncCallback(req,resp);
    }
}
